﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" Title="Login to Nexus" Theme="default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<style>
.desc
{
   font-size: 23px;
   color: #004182;
}
body
{
   background-color:#98b2cc;
   background-image: none;
}
.fineprint
{
   font-size:12px;
   height: 20px;
}
.walkthru
{
   font-size:14px;
}
</style>
<!-- Top Banner [Start] -->
<table border="0" width="500px" class="banner" align="center">
<tr>
   <td class="logo" width="100%"></td>
</tr>
<tr valign="top">
   <td>
   <br />
   <span class="desc">
   Nexus is a <b>space</b> for you to view what's <b>important</b> to you in a <b>glance</b>.
   </span>
   <br /><br />
   Click <a href="/tour">here</a> to have a tour of Nexus.
   <br /><br />
   Alternatively you can use the login panels below to login to your space.
   <br /><br />
   <div id="hint" class="fineprint"></div>
   <table border="0" width="100%">
   <tr valign="top">
      <td width="30%" style="border: solid 1px black;text-align:center" onmouseover="ShowHint(1)" onmouseout="ShowHint(0)">
         <h3>Campus Login</h3>
         <a href="/sso" 
         onmouseover='$get("login_sso_img").src="/images/login_sso_over.gif";'
         onmouseout='$get("login_sso_img").src="/images/login_sso.gif";'
         ><img src="/images/login_sso.gif" id="login_sso_img" border="0" /></a>
         <br />
         <br />
      </td>
      <td width="70%" style="border: solid 1px black;padding: 5px;" onmouseover="ShowHint(2)" onmouseout="ShowHint(0)">
         <h3>Web Login</h3>
<asp:UpdatePanel ID="Login_UpdatePanel" runat="server">
<ContentTemplate>
<asp:Literal ID="lbl_LoginError" runat="server" Text="Login failed, please check your userid and password" Visible="false" />
<table border="0">
<tr valign="top"><td>UserID</td><td>:</td><td>
<asp:DropDownList ID="ddl_Domain" runat="server">
<asp:ListItem>NUSSTU</asp:ListItem>
<asp:ListItem>NUSSTF</asp:ListItem>
<asp:ListItem>NUSALM</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txt_UserID" runat="server" Width="150px" /><asp:RequiredFieldValidator runat="server" ID="txt_UserID_Required" ControlToValidate="txt_UserID"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="true" ValidationGroup="Login" />
<AjaxCTK:TextBoxWatermarkExtender runat="server" ID="txt_UserID_WatermarkExtender"
TargetControlID="txt_UserID" WatermarkCssClass="watermarked" WatermarkText="NUSNET UserID" />
</td></tr>
<tr valign="top"><td>Password</td><td>:</td><td>
<asp:TextBox ID="txt_Password" runat="server" TextMode="Password" Width="95%"/><asp:RequiredFieldValidator runat="server" ID="txt_Password_Required" ControlToValidate="txt_Password"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="true" ValidationGroup="Login" />
</td></tr>
</table>
<asp:CheckBox runat="server" ID="cb_RememberMe" Text="Remember Me" />
<br />
<asp:Button ID="btn_Login" Text="Login" runat="server" onclick="btn_Login_Click" 
      ValidationGroup="Login" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="Login_UpdateProgress" runat="server" AssociatedUpdatePanelID="Login_UpdatePanel">
<ProgressTemplate>
<img src="/images/ajax_circle.gif" border="0" />Please wait while we verify your entry.
</ProgressTemplate>
</asp:UpdateProgress>       
      </td>
   </tr>
   </table>
   </td>
</tr>
</table>
<!-- Top Banner [End] -->

<script type="text/javascript">
      function UserID_KeyPress(e)
      {
         var keyCode = 0;
      	if (!e) var e = window.event;
         keyCode = e.keyCode;
         
         if (keyCode == 13)
         {
            e.cancel = true;         
            e.returnValue = false;
            <%= btn_Login.ClientID %>.click();
         }
         
         var x = "";
         
         var ddlDomain = document.getElementById("<%= ddl_Domain.ClientID %>");
         if (this.value.length > 2)
         {
            //students is gXXX or uXXX, iscXXXX
            //staff is 3 character codes
            var val = this.value + String.fromCharCode(keyCode);
            //alert(val.substring(2));
            if (isNaN(parseInt(val.substring(2))))
            {
               ddlDomain.value = "NUSSTF";
            }
            else
            {
               ddlDomain.value = "NUSSTU";
            }
         }         
      }
     function pageLoad() {
         //var modalPopupBehavior = $find('LoginModalPopupBehavior');
         //modalPopupBehavior.show();
         document.getElementById('<%= txt_UserID.ClientID %>').onkeypress = UserID_KeyPress;
         document.getElementById('<%= txt_UserID.ClientID %>').focus();
      }
      
      function ShowHint(id)
      {
         var div = $get("hint");
         
         switch(id)
         {
            case 1:
               div.innerHTML="<img src='/images/hint.png' border='0' />&nbsp;Click on the 'Enter' button to perform an automatic windows login";         
               break;
            case 2:
               div.innerHTML="<img src='/images/hint.png' border='0' />&nbsp;Use this form to perform a manual login process";
               break;
            default:
               div.innerHTML = "";
               break;
         }
         
      }
</script>


</asp:Content>

